/* 
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */


function mimcz() {
    var mmcz = d3.select("body").append("div").classed("mmcz", true).style({
        position: "absolute",
        width: "100%",
        height: "100%",
        left: "100%"
    });
    $(".dt_warp").css("position","absolute");
    $(".dt_warp").animate({left: "-100%"}, Transiacion);
    $(".mmcz").animate({left: "0%", top: "0%"}, Transiacion);
    var sz_bg = mmcz.append("div").classed("sz_bg", true);
    var head = sz_bg.append("div").classed("datong_header", true);
    head.append("h1").html("修改密码").classed("h_title", true);
    var go_back = head.append("div").classed("go_back", true);
    go_back.html("<i><img src =../../common/page/images/go_back_ico.png width =16 height=auto></i>返回");
    go_back.on(touch_s, function() {
        $(this).css("background-color", "#005ebf");
    });
    go_back.on(touch_e, function() {
        $(this).css("background-color", "");
        $(".dt_warp").animate({left: "0px"}, Transiacion );
        $(".mmcz").animate({left: "100%"}, Transiacion , function() {
            $(this).remove();
        });
    });
  var sz=  sz_bg.append("div").classed("datong_con ,datong_con2", true);
   //edit by lixuefang,重置密码
  var string='';
  string +='<p>请为您的账号'+window.localStorage['userName']+'修改密码，为保障您的账号安全，修改密码前请填写原密码</p>';
  string +='<table class="minmcz-table">';
  string +='<tr><td><input type="password" name="password_o" placeholder="请输入原密码"></td></tr>';
  string +='<tr><td><input type="password" name="password" placeholder="请输入新密码"></td></tr>';
  string +='<tr><td><input type="password" name="password1" placeholder="请再一次输入新密码"></td></tr>';
  string +='<tr><td align="center" border="0"><button onclick="resetPassword()">完成</button></td></tr>';
  string +='</table>';
  sz.append("div").classed("phone_cotent",true).html(string).style({
        "border":"none",
        "font-size":"1.1em",
        "line-height":"30px"
    });
  $('input[name="password_o"]').focus();
    function back1() {
        $(".dt_warp").animate({left: "0px"}, Transiacion );
        $(".mmcz").animate({left: "100%"}, Transiacion , function() {
            $(this).remove();
        });
        Android.back = TempFunction.back;
    }
    Android.back = TempFunction.back1=back1;
}
function resetPassword()
{
	var oldPass=$('input[name="password_o"]').val();
	var newPass=$('input[name="password"]').val();
	var newPass1=$('input[name="password1"]').val();
	if($.md5("dtoa"+oldPass) != window.localStorage['passWord']){
		Prompt("原密码输入错误，请重新输入！");
		return;	
	}
	if(newPass != newPass1){
		Prompt("两次密码不一致，请重新输入！");
		return;
	}
	if(newPass == newPass1 && newPass==''){
		Prompt("新密码不能为空，请重新输入！");
		return;
	}
	if(newPass == newPass1 && newPass.length<6){
		Prompt("新密码长度不能少于6位，请重新输入！");
		return;
	}
	var url=serverURL+"cmcp/user/updatePassword";
	$.ajax({
		url: url,
		type: "POST",
		async: true,
		timeout: 20000,
		data: {"password": newPass},
		success: function (Data, textStatus, XMLhttpRequest) {
			if(Data == 'success'){
				Alert("重置密码成功");
				window.localStorage.passWord=$.md5("dtoa"+newPass);
				$(".dt_warp").animate({left: "0px"}, Transiacion );
				$(".mmcz").animate({left: "100%"}, Transiacion , function() {
					$(this).remove();
				});
			}
		},
		beforeSend: function () {
			if (showType == "none") {
				if (isMobile.Android())
					navigator.notification.activityStart("政府OA系统", "请等待...");
			}
			showType = "true"
		},
		complete: function () {
			showType = "false"
			setTimeout(function () {
				if (showType == "false") {
					showType = "none"
					if (isMobile.Android())
						navigator.notification.activityStop();
				}
			}, 500);

			;
		},
		error: function (a, b) {
			// 提示错误信息
			console.log("err");
			Alert("密码重置失败");
			//  window.plugins.getIntent.hide();

		}
	});
}